<template>
	<el-drawer :title="titleMap[mode]" v-model="visible" :size="600" append-to-body destroy-on-close @closed="$emit('closed')">
		<el-container>
			<el-main class="nopadding">
				<el-scrollbar>
					<el-row class="drawer-table">
						<el-col :span="24">
							<el-form :model="form" :rules="rules" :disabled="mode==='show'" ref="dialogForm" label-width="80px">
								<el-form-item label="登录验证码" prop="appUserLoginId">
									<el-input v-model="form.appUserLoginId" placeholder="请输入登录验证码" clearable></el-input>
								</el-form-item>
								<el-form-item label="用户id" prop="appUserId">
									<el-input v-model="form.appUserId" placeholder="请输入用户id" clearable></el-input>
								</el-form-item>
								<el-form-item label="电话号码 唯一标识" prop="telphone">
									<el-input v-model="form.telphone" placeholder="请输入电话号码 唯一标识" clearable></el-input>
								</el-form-item>
								<el-form-item label="0待验证 1已验证成功 2验证失败" prop="state">
									<el-input v-model="form.state" placeholder="请输入0待验证 1已验证成功 2验证失败" clearable></el-input>
								</el-form-item>
								<el-form-item label="0待发送  1发送成功 2发送中 3发送失败" prop="sendState">
									<el-input v-model="form.sendState" placeholder="请输入0待发送  1发送成功 2发送中 3发送失败" clearable></el-input>
								</el-form-item>
								<el-form-item label="登录次数" prop="intCount">
									<el-input v-model="form.intCount" placeholder="请输入登录次数" clearable></el-input>
								</el-form-item>
								<el-form-item label="验证 记录" prop="regLog">
									<el-input v-model="form.regLog" placeholder="请输入验证 记录" clearable></el-input>
								</el-form-item>
								<el-form-item label="验证码 sf其他,wx微信,fb脸书,dsf第三方,zj直接,xt相同手机、卡号,xtSj相同手机、卡号商家" prop="recode">
									<el-input v-model="form.recode" placeholder="请输入验证码 sf其他,wx微信,fb脸书,dsf第三方,zj直接,xt相同手机、卡号,xtSj相同手机、卡号商家" clearable></el-input>
								</el-form-item>
								<el-form-item label="推广员编码" prop="promoteNum">
									<el-input v-model="form.promoteNum" placeholder="请输入推广员编码" clearable></el-input>
								</el-form-item>
								<el-form-item label="验证时间" prop="updateTime">
									<el-input v-model="form.updateTime" placeholder="请输入验证时间" clearable></el-input>
								</el-form-item>
								<el-form-item label="创建时间" prop="createTime">
									<el-input v-model="form.createTime" placeholder="请输入创建时间" clearable></el-input>
								</el-form-item>
								<el-form-item label="手机类型 1MPT  2Teleno 3Ooredoo 9others" prop="operators">
									<el-input v-model="form.operators" placeholder="请输入手机类型 1MPT  2Teleno 3Ooredoo 9others" clearable></el-input>
								</el-form-item>
								<el-form-item label="短信发送手机请求 记录" prop="smsReqId">
									<el-input v-model="form.smsReqId" placeholder="请输入短信发送手机请求 记录" clearable></el-input>
								</el-form-item>
								<el-form-item label="验证情况" prop="doMsg">
									<el-input v-model="form.doMsg" placeholder="请输入验证情况" clearable></el-input>
								</el-form-item>
								<el-form-item label="手机唯一标识" prop="vsid">
									<el-input v-model="form.vsid" placeholder="请输入手机唯一标识" clearable></el-input>
								</el-form-item>
                            </el-form>
						</el-col>
					</el-row>
				</el-scrollbar>
			</el-main>
			<el-footer>
				<el-button v-if="mode!=='show'" :loading="isSaveing" @click="submit()" type="primary" size="small">保 存</el-button>
				<el-button size="small" @click="visible=false">取 消</el-button>
			</el-footer>
		</el-container>
	</el-drawer>
</template>
<script>
	export default {
		emits: ['success', 'closed'],
		data() {
			return {
				mode: "add",
				titleMap: {
					add: '新增',
					edit: '编辑',
					mode: '登录记录'
				},
				visible: false,
				isSaveing: false,
				//表单数据
				form: {
					appUserLoginId: "",
					appUserId: "",
					telphone: "",
					state: "",
					sendState: "",
					intCount: "",
					regLog: "",
					recode: "",
					promoteNum: "",
					updateTime: "",
					createTime: "",
					operators: "",
					smsReqId: "",
					doMsg: "",
					vsid: "",
				},
				//验证规则
				rules: {
					userName: [
						{required: true, message: '请输入名称'}
					],
					userAge: [
						{pattern: /^[0-9]*$/, message: '年龄需为数字', trigger: 'blur'}
					],
					price: [
						{pattern: /^\d+(\.\d+)?$/, message: '价格需为数字', trigger: 'blur'}
					]
				}
			}
		},
		mounted() {

		},
		methods: {
			//显示
			open(mode='add'){
				this.mode = mode;
				this.visible = true;
				return this;
			},
			//表单提交方法
			submit(){
				this.$refs.dialogForm.validate(async (valid) => {
					if(valid){
						this.isSaveing = true;
						var res = await this.$API.hygl.hyAppUserLogin.save.post(this.form);
						this.isSaveing = false;
						if(res.code === 2000){
							this.$emit('success', this.form, this.mode);
							this.visible = false;
							this.$message.success(res.message);
						}else{
							this.$alert(res.message, "提示", {type: 'error'})
						}
					}
				});
			},
			//表单注入数据
			setData(data){
				this.form.appUserLoginId = data.appUserLoginId;
				this.form.appUserId = data.appUserId;
				this.form.telphone = data.telphone;
				this.form.state = data.state;
				this.form.sendState = data.sendState;
				this.form.intCount = data.intCount;
				this.form.regLog = data.regLog;
				this.form.recode = data.recode;
				this.form.promoteNum = data.promoteNum;
				this.form.updateTime = data.updateTime;
				this.form.createTime = data.createTime;
				this.form.operators = data.operators;
				this.form.smsReqId = data.smsReqId;
				this.form.doMsg = data.doMsg;
				this.form.vsid = data.vsid;
			}
		}
	}
</script>
<style>
</style>
